var dd = {
	'field':'',//大类
	'childfield':'',//小类
	'to_id':'',//code赋值
	'to_text':'',//value赋值
	'is_multi':'',//多选开关
	'show_full':'',//是否显示不限
	'is_loc':'',//定位开关
	'empty':'',//是否可提交空值
	'title':'',
	'unlimit':''
};

var setChild = function(o)
{
	var next = $(o).next();
	if(next.hasClass('lsinfo'))
	{
		if(next.css('display') == 'none')
		{
			$('.lsinfo').hide();
			$('.down').removeClass('down');
			$(o).addClass('down');
			next.show();
		}
		else
		{
			$(o).removeClass('down');
			next.hide();
		}
	}
	else
	{
		var	code = eval(dd.childfield + '_c'),
			value = eval(dd.childfield + '_v'),
			fathercode = $(o).attr('value');
		if(dd.field.indexOf('area') != -1)
		{
			var htm = '<div class="lsinfo" style="display:block">',
				trigger = true,
				id = new Array();
			$('.barea').each(function(){
				id.push($(this).attr('value'));
			});
			id = id.toString();
			for(var ele in code)
			{
				if(code[ele].substr(0,2) == fathercode.substr(0,2))
				{
					if(dd.is_loc)
					{
						htm += '<i value="' + code[ele] + '" onclick="setLoc(this,\'' + domain + '\')">' + value[ele] + '</i>';
					}
					else
					{
						if(dd.is_multi)
						{
							var ck = '';
							if(id.indexOf(code[ele]) != -1)
							{
								ck = ' class="on"';
							}
							htm += '<i' + ck + ' id="barea_' + code[ele] + '" value="' + code[ele] + '" onclick="selAreaMulti(this)">' + value[ele] + '</i>';
						}
						else
						{
							htm += '<i value="' + code[ele] + '" onclick="selVal(this)">' + value[ele] + '</i>';
						}
					}
					trigger = false;
				}
			}
			if(trigger)
			{
				if(is_loc)
				{
					setLoc(o,domain);
				}
				else
				{
					selVal(o);
				}
				return false;
			}
			htm += '<div class="clear"></div></div>';
		}
		else
		{
			var htm = '<p class="lsinfo" style="display:block">';
			for(var ele in code)
			{
				if(dd.is_multi == 1 && $(o).attr('value') == dd.unlimit)
				{
					selMulti(o);
					return false;
				}
				if(code[ele].substr(0,2) == fathercode.substr(0,2))
				{
					if(dd.is_multi == 1)
					{
						var id = $('#' + dd.field + '_' + dd.unlimit).hasClass('ck') ? '' : $('#' + dd.to_id).val();
						if(id.indexOf(code[ele]) != -1)
						{
							var ck = 'ck';
						}
						else
						{
							var ck = 'nr';
						}
						htm += '<span class="i ' + ck + '" value="' + code[ele] + '" id="' + dd.field + '_' + code[ele] +'" onclick="selMulti(this)">' + value[ele] + '</span>';
					}
					else
					{
						htm += '<span class="i nr" value="' + code[ele] + '" onclick="selVal(this)">' + value[ele] + '</span>';
					}
					trigger = false;
				}
			}
			htm += '</p>';
		}
		$('.lsinfo').hide();
		$('.down').removeClass('down');
		$(o).addClass('down');
		$(o).after(htm);
	}
}



